<TABLE width='100%' height='100%' cellspacing="0" cellpadding="0">
<TR>
	<TD class='explorer_folder_action'>
		
	</TD>
</TR>
<TR>
	<TD class='explorer_folder_list'>
		<div class='explorer_div_list'>
		<?php
		
		$renameFile = get("renameFile");
		if(!in_array($path,$filterArray)){
			$parent = get_real_folder($currentPath . "../") ;
		}else{
			$parent = dirname($currentPath).'/' ;
			
		}
		//echo $parent ."<br>";
		//echo $currentPath ."<br>";
		//echo $root ;
		
		
		//读取目录中的文件
		//echo $currentPath ;
		
		if ((($d = dir($currentPath)) != "") || in_array($path,$filterArray)){
			//echo "Path: " . $d->path . "\n";
			$files = array() ;
			if(basename($root) != 'attachment'){
				while($file = $d->read()){
					if ($file=='.' || $file=='..'){
					   continue ;
					}
					clearstatcache();
					$files[]=array(date("Y-m-d H:i:s", filemtime($currentPath . $file)),
									is_dir("$currentPath/$file") ? "folder" : strrchr($currentPath . $file, '.'),
									is_dir("$currentPath/$file") ? get_dir_size($currentPath . $file) : filesize($currentPath . $file),
									$file);
				}
				$d-> close(); 
				//把目录中的文件按最后修改时间倒序排列
				if(is_array($files)){
					rsort($files);
				}
			}else{
				$files = getAttachByPath($currentPath) ;
				//print_r($files) ;
				
			
			}
			
			//列出排序后的文件
			for($x=0;$x<count($files);$x++){
				$lastModify = $files[$x][0];
				$fileTypeName = $files[$x][1];
				$fileSize = $files[$x][2];
				$file = $files[$x][3];
				$fileName = to_php_encoding($file) ;

				if($path != 'attachment'){
					$isDir = is_dir("$currentPath/$file") ;
				}else{
					$temp_path = $files[$x]['attachment_path'] ;
					if(!file_exists($temp_path)){
						continue ;
					}
					$attachmentId = $files[$x]['attachment_id'] ;
					$isFile = $files[$x]['is_file'];
					$isDir = $isFile  ;
					if($isDir){
						//echo $temp_path ;
						$fileSize = get_dir_size($temp_path) ;
					}
				}
				$icon = $isDir? "<img src='./icons/folder_new.gif'></img>" : "" ;
				//$lastModify = date("Y-m-d H:i:s", filectime($currentPath . $file));
				//$fileTypeName = $isDir ? "folder" : strrchr($currentPath . $file, '.') ;
				//$fileSize = filesize($currentPath . $file);
				$row_class = 'row_'.($x%2) ;
				if($root != $currentPath && $size1 < $size2){
					$num = ($x%2) == 0?1:0 ;
					$row_class = 'row_'.$num ;
				}
				echo "<tr class='$row_class'>";
				echo "	<td class='cell_center' style='border-left:0px;'>$icon</td>";
				echo "	<td class='cell'>";
				
				if($renameFile == $fileName){
					echo "<form name='form1' method='post' target='newwin' action='actions.php' style='text-align:left;' onsubmit='return submitRename2()'>";
					if($isDir){
						echo "<INPUT TYPE='hidden' name='is_dir' value='folder'>" ;
					}
					echo "<INPUT TYPE='hidden' name='system_flag' value='rename'>";
					echo "<INPUT TYPE='hidden' name='old_name' value='$fileName'>";
					echo "<input type='text' size='32' name='new_name' id='new_name' value='$fileName' onblur='submitRename(this)'>";
					echo "</form>";
				}else{
					if($isDir){
						echo "<a href='#' onclick=\"enterIn('".to_php_encoding($currentPath) . $fileName ."/')\">";
					}else{
						if($path != 'attachment'){
							echo "<a href='#' onclick=\"chooseFile('$fileName','".to_php_encoding($currentPath.$file)."','$formate')\">";
						}else{
							echo "<a href='#' id='$attachmentId'  onclick=\"chooseAttachment('$fileName',$fileSize,$attachmentId)\">";
						
						
						}
					}
					echo $fileName;
					//echo iconv("gbk","gbk",$fileName) ;
					echo "</a>";
				}
				
				$admin_user_id = getSession("access_admin_user_id","");
				$on_rename = "onclick=\"rename('".$fileName ."','".$path."')\"" ;
				if($admin_user_id != "" && basename($root) == 'exportReport'){
					 $on_rename = '' ;
				}
				 
				echo "	</td>";
				echo "	<td class='cell_center'>$lastModify</td>";
				echo "	<td class='cell_center'>$fileTypeName</td>";
				echo "	<td class='cell_center'>".unitConversion($fileSize)."</td>";
				echo "	<td class='cell_center' style='border-right:0px;'><A HREF='#' 
				$on_rename>".label("common.rename")."</A>";
				echo "	<A HREF='#' 
				onclick=\"deleteFile('".$fileName ."','".$isDir."','".$path."')\">".label("common.delete")."</A>";
				
				if(!$isDir){
					echo "  <A HREF='#' onclick=\"download_file('".$fileName."')\">".label("common.download")."</A>";
				}
				echo "	</td>";
				echo "</tr>";
			}
		}
		echo "</TABLE>";
		?>
		</div>
	</TD>
</TR>
<TR class='row_1'>
	<TD class='explorer_folder_upload'>
	
	</TD>
</TR> 
</TABLE>